package org.linlinjava.litemall.db.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.linlinjava.litemall.db.entity.Gamch;
import org.linlinjava.litemall.db.mapper.GamchMapper;
import org.linlinjava.litemall.db.service.IGamchService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 * 主播商户 服务实现类
 * </p>
 *
 * @author shuyi
 * @since 2019-11-14
 */
@Service
public class GamchServiceImpl extends ServiceImpl<GamchMapper, Gamch> implements IGamchService {

    @Resource
    private GamchMapper gamchMapper;

    @Override
    public Gamch findByUid(Integer id) {
        QueryWrapper<Gamch> wrapper = new QueryWrapper<>();
        wrapper.eq("uid",id).gt("istatus",0);
        return gamchMapper.selectOne(wrapper);
    }

    @Override
    public boolean canApply(int uid) {
        QueryWrapper<Gamch> qw=new QueryWrapper<>();
        qw.eq("uid",uid).gt("istatus",0);
        return gamchMapper.selectCount(qw)<1;
    }
}
